package crane.bomb;

import javax.swing.JFrame;
import javax.swing.JMenuBar;

/**
 * 
 * @author crane
 *
 */
public class Main {

    /**
     * 
     * @param args
     */
    public static final void main(String[] args){
        Main main = new Main();
        main.paintPage();
    }
    
    /**
     * Paint page
     *
     */
    private void paintPage(){
        
        JFrame frame = new JFrame();
        BombAction action = new BombAction();
        MainBean mBean = new MainBean();
        
        // paint menubar
        MainMenu mm = new MainMenu();
        JMenuBar mbar = mm.buileMenuBar(frame);        
        frame.setJMenuBar(mbar);
        mBean.setFrame(frame);
        
        BombFrame bombFrame = new BombFrame();
        bombFrame.paintFrame(frame);
        bombFrame.setBombArray(new BombArray(bombFrame.getXLength(), 
                bombFrame.getYLength(), bombFrame.getLevel()));
        mBean.setBombFrame(bombFrame);
        action.setAllButtonToBean(bombFrame);
        
        mm.setMainBean(mBean);
        bombFrame.setMainBean(mBean);
        
        // set properties
        int xSize =  bombFrame.getXLength() * BombFrame.DEFAULT_BUTTON_WIDTH;
        int ySize =  bombFrame.getYLength() * BombFrame.DEFAULT_BUTTON_HEIGHT;
        frame.setBounds(300, 190, xSize, ySize);
        frame.pack();
        frame.setResizable(false);
        frame.setVisible(true);
        frame.addWindowListener(new ActionAdapter());
    }
}
